package com.github.ginirohikocha.bean;

import java.sql.*;

public class Database {
	public static final String DATABASE_URL = "jdbc:mysql://localhost:3306/kcsj?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC";

	private static final String DATABASE_USER_NAME = "root";
	private static final String DATABASE_USER_PASSWORD = "22090810";
	
	private Connection dbCon;

	public Database() {
		try {
			Class.forName("com.mysql.cj.jdbc.Driver");
			dbCon = DriverManager.getConnection(DATABASE_URL, DATABASE_USER_NAME, DATABASE_USER_PASSWORD);
		} catch (ClassNotFoundException | SQLException e) {
			e.printStackTrace();
		}
	}

	public Connection getDbCon() {
		return dbCon;
	}

	public void setDbCon(Connection dbCon) {
		this.dbCon = dbCon;
	}

	public void close() {
		try {
			dbCon.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
